import pymysql



def select(sql):
    db = pymysql.connect(host="localhost", user="root", password="123456", database="project_01")
    cursor = db.cursor()
    try:
        cursor.execute(sql)
        result = cursor.fetchall()
        print('successful')
        return result
    except:
        import traceback

        traceback.print_exc()
        print("Error: unable to fetch data")
    db.close()


print(select('select * from physics_value_table where project="201111"'))

a = select('select ph_name from physics_value_table where project="201111"')
print(a)
b = []
e = {}
for i in a:
    print(i[0])
    if i[0] not in b:
        b.append(i[0])
print(b)
for i in b:
    print(i)
    c = select('select num from physics_value_table where ph_name="%s"'%(i))
    print(c)
    d = []
    for t in c:
        d.append(t[0])
    print(d)
    e[i] = d
print(e)